package cn.mcartoon.serviceImpl;
import cn.mcartoon.mapper.MmUsersMapper;
import cn.mcartoon.pojo.MmUsers;
import cn.mcartoon.service.MmUsersService;
import cn.mcartoon.dto.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.ArrayList;
import java.util.HashMap;
@Service
public class MmUsersServiceImpl implements MmUsersService {

    @Autowired
    private MmUsersMapper mmUsersMapper;

    public MmUsers getMmUsersById(Long id){
        return mmUsersMapper.getMmUsersById(id);
    }

    public List<MmUsers>	getMmUsersListByMap(Map<String,Object> param){
        return mmUsersMapper.getMmUsersListByMap(param);
    }

    public Integer getMmUsersCountByMap(Map<String,Object> param){
        return mmUsersMapper.getMmUsersCountByMap(param);
    }

    public Integer insertMmUsers(MmUsers mmUsers){
            return mmUsersMapper.insertMmUsers(mmUsers);
    }

    public Integer updateMmUsers(MmUsers mmUsers){
        return mmUsersMapper.updateMmUsers(mmUsers);
    }

    public Integer deleteMmUsersById(Long id){
        return mmUsersMapper.deleteMmUsersById(id);
    }

    public Integer batchDeleteMmUsers(String ids){
        Map<String,List<String>> param=new HashMap<String,List<String>>();
        String[] paramArrays=ids.split(",");
        List<String> idList=new ArrayList<String>();
            for (String temp:paramArrays){
                idList.add(temp);
            }
        param.put("ids",idList);
        return mmUsersMapper.batchDeleteMmUsers(param);
    }

    public Page<MmUsers> queryMmUsersPageByMap(Map<String,Object> param,Integer pageNo,Integer pageSize){
        Integer total = mmUsersMapper.getMmUsersCountByMap(param);
        Page page = new Page(pageNo, pageSize, total);
        param.put("beginPos", page.getBeginPos());
        param.put("pageSize", page.getPageSize());
        List<MmUsers> mmUsersList = mmUsersMapper.getMmUsersListByMap(param);
        page.setList(mmUsersList);
        return page;
     }


}
